package com.example.common;

import com.alibaba.fastjson.JSON;

/**
 * @author dangwen1
 * @date 2022年01月06日 14:55
 * @description
 */
public class Insertion {
    public static void main(String[] args) {
        int[] array = new int[]{1,21,2134,231,312,4,45,65,9,67,8,8,};
        int preIndex, current;
        for (int i = 1; i < array.length; i++) {
            preIndex = i - 1;
            current = array[i];
            while (preIndex >= 0 && array[preIndex] > current) {
                array[preIndex + 1] = array[preIndex];
                preIndex--;
            }
            array[preIndex + 1] = current;
        }
        System.out.println(JSON.toJSONString(array));
    }
}
